{% extends 'account/base.html' %}
{% load static %}

{% block title %}
    <title>登陆|MYCRM</title>
{% endblock title %}

{% block head %}
    <h1>CRM</h1>
    <div class="connect">
        <p style="left: 0%;">Link the world. Share to world.</p>
    </div>
{% endblock head %}
{% block content %}
    <form action="{% url 'sales:login' %}" method="post" id="loginForm"
          novalidate="novalidate">
        {% csrf_token %}
        {% for field in login_form %}
            <div>
                <span class="errors"></span>
                {{ field }}
                <span class="error-tips">{{ field.errors.0 }}</span>
            </div>
        {% endfor %}
        <button id="submit" type="submit">登 陆</button>
    </form>
    <a href="{% url 'sales:register' %}">
        <button type="" class="register-tis">还有没有账号？</button>
    </a>
{% endblock content %}

{#{% block custom_js %}#}
{#    <script>#}
{#        $(document).ready(function () {#}
{#            var submit = $("#submit");#}
{#            submit.click(function () {#}
{#                var username = $("#id_username").val();#}
{#                var password = $("#id_password").val();#}
{#                var url = $("form").attr('action');#}
{#                var csrf_token = $("[name='csrfmiddlewaretoken']").val();#}
{#                $.ajax({#}
{#                    url: url,#}
{#                    type: 'POST',#}
{#                    data: {'username': username, 'password': password, 'csrfmiddlewaretoken': csrf_token},#}
{#                    success: function (response) {#}
{#                        if (response.status == 'success') {#}
{#                            window.location.href = '/home/';#}
{#                        } else {#}
{#                            $(".errors").text(response.error_msg);#}
{#                        }#}
{#                    }#}
{#                })#}
{#            })#}
{#        })#}
{#    </script>#}
{#{% endblock custom_js %}#}



